let nums = [100,4,200,1,3,2]
var longestConsecutive = function(nums) {
    let set = new Set(nums)
    let ans = 0
    for(let item of set){
        if(set.has(item-1)){
            continue
        }
        let y = item+1
        while(set.has(y)){
            y +=1
        }
        ans = Math.max(ans,y-item)
    }
    return ans
};
console.log(longestConsecutive(nums));
